package com.tianji.learning.controller;

import com.tianji.learning.dto.QuestionFormDTO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

@Api(tags = "问答系统相关接口")
@RestController
@RequestMapping("/questions")
public class InteractionQuestionController {

    @Resource
    private IInteractionQuestionService questionService;

    @PostMapping
    @ApiOperation("新增互动问题")
    public void saveQuestion(@RequestBody @Valid QuestionFormDTO questionForm) {
        questionService.saveQuestion(questionForm);
    }

    @PutMapping("{id}")
    @ApiOperation("修改互动问题")
    public void updateQuestion(@PathVariable Long id, @RequestBody @Valid QuestionFormDTO questionForm) {
        questionService.updateQuestion(id, questionForm);
    }

    @DeleteMapping("{id}")
    @ApiOperation("删除互动问题")
    public void deleteQuestion(@PathVariable Long id) {
        questionService.deleteQuestion(id);
    }
}